<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@	page import="kau.dao.*"%>
<%@	page import="kau.vo.*"%>
<%@ page import="java.util.ArrayList"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<html>
<head>


<script type="text/javascript">
	function enrollfunction(courseId, custId) {
		//	alert(courseId);
		//	alert(custId);
		var theForm = document.f;
		theForm.method = "post";
		theForm.action = "insert.registeration?custId=" + custId + "&courseId="
				+ courseId + "&isConfirm=0";

		theForm.submit();
		//여기에 수강신청 복수신청시 이미 신청하였다는 메시지 출력
		//아니면 아예 중복수강신청 불가하게 해야한다.

	}
</script>

<style type="text/css">
<!--
@import url("css/style.css");
-->
</style>

<style type="text/css">
#info {
	font-family: 맑은 고딕, dotum, sans-serif, bold;
	font-size: 13px
}
</style>


</head>


<body>



	<div id="info">

			<br>
			<table align="left" style="margin-left: 20px">
				<tr>

				<td width="60" height="50">
					<img src="/nems/cust/img/enroll_image.png" width="40" alt="수강신청" /> 
					</td>
					
					<td>
					<h4	style=" font-weight: bold; color: #005700; text-align: left; font-size: 20px;">수강신청</h4>
					</td>
				</tr>
			</table>
			
			<br><br><br><br>
			
		</div>
	<form name="f">

		
		<table id="newspaper-a" style="width: 750px">

			<thead>
				<tr align="center">
					<th scope="col" width="3%">No.</th>
					<th scope="col" width="27%">강의</th>
					<th scope="col" width="16%">강사명</th>
					<th scope="col" width="17%">시작날짜</th>
					<th scope="col" width="17%">종료날짜</th>
					<th scope="col" width="5%">시작시간</th>
					<th scope="col" width="5%">종료시간</th>
					<th scope="col" width="5%">수강신청</th>
				</tr>
			</thead>

			<c:set value="${sessionScope.custId}" var="custId"></c:set>
			<c:set value="${requestScope.registerList}" var="registerList"></c:set>
			<c:set value="${requestScope.existList}" var="existList"></c:set>

			<tbody>
				<c:forEach items="${requestScope.courseList}" var="courseList"
					varStatus="status">

					<tr align="center">
						<td>${status.index+1}</td>
						<td>${courseList.courseName}</td>
						<td>${courseList.lecturer}</td>
						<td>${courseList.startDate}</td>
						<td>${courseList.endDate}</td>
						<td>${courseList.startTime}</td>
						<td>${courseList.endTime}</td>


						<c:choose>
							<c:when test="${existList[status.index] == 1}">
								<td><button style="width: 70px" disabled>
										<img src="/nems/cust/img/tick.png"
											style="width: 20px; height: 10px" />완료
									</button></td>

							</c:when>
							<c:when test="${existList[status.index] == 0}">
								<td><button class="positive" style="width: 70px" type="button"
										onclick="enrollfunction('${courseList.courseId}','${custId}')">
										<img src="cust/img/shopping_cart_accept.png"
											style="width: 20px; height: 10px" />신청
									</button></td>
							</c:when>
						</c:choose>

					</tr>
				</c:forEach>
			</tbody>
		</table>
	</form>
<br>
	<center>
		<a href="index.jsp?contentMenu=/cust/myPage.jsp&content=/cust/mainPage.jsp" class="css_btn_class">이전화면으로</a>
	</center>


</body>
</html>